package org.sdsds222.testtlias.mapper;

import org.apache.ibatis.annotations.*;
import org.sdsds222.testtlias.pojo.*;

import java.util.List;

/**
 * 部门管理
 */
@Mapper
public interface UniAppMapper {

    @Select("select * from nav")
    List<Nav> getAllNavList();

    @Select("select * from news where classid = #{cid}")
    List<News> getAllNewsListByCid(Integer cid);

    @Select("select * from detail where classid = ${cid} and newsid = #{id}")
    Detail getDetailByCidAndId(Integer cid, Integer id);

    @Select("select * from comment where classid = #{cid} and newsid = #{id}")
    List<Comment> getCommentsByCidAndId(Integer cid, Integer id);

    void addPublishContentToNews(PublishContent publishContent);

    void addPublishContentToDetail(PublishContent publishContent);

    @Insert(" INSERT INTO comment (classid,newsid,text,posttime,username) VALUES (#{cid}, #{id}, #{text}, #{posttime},#{username})")
    void addCommentPublishContentToComment(CommentPublishContent commentPublishContent);

    @Update("UPDATE news SET hits = hits + 1 WHERE classid = #{cid} and id=#{id}")
    void updateHitsByCidAndId(Integer cid, Integer id);
}
